"""
CPEM Schedule (lib/Schedule.py)   
Copyright 2010, C.J. Steele, all rights reserved.

C.J. Steele <coreyjsteele@gmail.com>

Schedule class creates a Schedule object which are registered in the Registry, 
and which are executed by the scheduler plugin. 


TODO: this needs to be finished.
"""

import time

class Schedule:
    """Schedule Class
    Creates a schedule object based off of an interval, a start-time, and a 
    stop-time
    """

    schedInterval = 0
    schedStart = 0
    schedItters = 0

    def __init__(self,interval='1h',start=time.time(),itterations=0):
        ''' intervals may be: m, h, d'''
        if interval.len() is not 2:
            return False

        multiplier = int(interval[0])
        duration = interval[1]

        if duration.lower() is 'm':
            multiplier = int(multiplier) * 1
        elif duration.lower() is 'h':
            multiplier = int(multiplier) * 60
        elif duration.lower() is 'd':
            multiplier = int(multiplier) * 60 * 24
        else:
            multiplier = 0

        self.schedInterval = multiplier
        self.schedStart = start
        self.schedItters = itterations

        return True
